﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
using Media.Core.Data;
using Media.Core.Models;

namespace Media.Core.Helpers.Main
{
    public class GetMenuByRole
    {
        public static RolesArray GetMenu(string User)
        {
            var db = new Database();
            if (User == null) { User = ""; }

            ArrayList paramsList = new ArrayList
            {
                new SqlParameter("UserName", User)
            };

            var DataMenu = Data.Connections.GetDataTable("Main_Get_MenuByRole", paramsList, "MovieDBContext");

            var Menus = new RolesArray();

            foreach (DataRow menu in DataMenu.Rows)
            {
                Menus.Role.Add(new Roles
                {
                    MenuText = menu["MenuText"].ToString(),
                    PageName = menu["PageName"].ToString(),
                    Controller = menu["ControllerName"].ToString()
                });
            }

            return Menus;
        }
    }
}